package com.jiangfeixiang.springbootblog.controller.admin;

import com.jiangfeixiang.springbootblog.entity.Contents;
import com.jiangfeixiang.springbootblog.service.ContentsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

/**
 * @Author: 姜飞祥
 * @Description:
 * @Date: Create in 2019/1/27/0027 20:47
 * @param: $params$
 * @return: $returns$
 */
@Controller
@RequestMapping("/admin")
public class ContentsController {

    @Autowired
    private ContentsService contentsService;

    /**
     * 进入markdown编辑页
     * @return
     */
    @RequestMapping("/blogEdit")
    public String simple(){
        //这里的文件名将直接定位到templates下面的文件
        return "admin/blogEdit";
    }

    /**
     * 提交markdown内容
     * @param contents
     * @return
     */
    @RequestMapping(value = "/contentCommit",method = RequestMethod.POST)
    public String contentCommit(Contents contents){
        contentsService.contentCommit(contents);
        System.out.println("成功插入");
        return "redirect:/admin/index";
    }
}
